package adapter;

import java.util.ArrayList;

import com.ming.inthefridge.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;



public class MainFridgeAdapter extends BaseAdapter {
	Context maincon;
	LayoutInflater Inflater;
	ArrayList<MainFridgeItem> arSrc;
	int layout;
	int type;

	
	public MainFridgeAdapter(Context context, int alayout, ArrayList<MainFridgeItem> aarSrc){
		maincon = context;
		Inflater = (LayoutInflater)maincon.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		arSrc = aarSrc;
		layout = alayout;
	}
	
	public int getCount(){
		return arSrc.size();
	}
	public MainFridgeItem getItem(int position){
		return arSrc.get(position);
	}
	public long getItemId(int position){
		return position;
	}
	
	public View getView(int position, View convertView, ViewGroup parent){
		final int pos = position;
		if(convertView == null){
			convertView = Inflater.inflate(layout, parent, false);
		}
		
		TextView fname_txt = (TextView)convertView.findViewById(R.id.fridgeNameText);
		fname_txt.setText(arSrc.get(pos).Name);
		
		TextView dday_txt = (TextView)convertView.findViewById(R.id.fridgeDdayText);
		dday_txt.setText(arSrc.get(pos).DDay);
		return convertView;
	}
   
}

